package qianlong.practice.mapper;

import org.apache.ibatis.annotations.*;
import qianlong.practice.entity.User;

import java.util.List;

@Mapper
public interface UserMapper {

    @Insert("insert into user(name,pass,age)values(#{name},#{pass},#{age})")
    int insert(User user);

    @Update("update user set name=#{name},pass=#{pass},age=#{age} where id=#{id}")
    int update(User user);

    @Delete("delete from user where id=#{id}")
    int delete(int id);

    @Select("select * from user where id=#{id}")
    User getOne(int id);

    @Select("select * from user")
    @Results(id = "userResultMap", value = {
            @Result(property = "id",column = "id", id = true),
            @Result(property = "name",column = "name"),
            @Result(property = "pass",column = "pass"),
            @Result(property = "age",column = "age")
    })
    List<User> getList(User user);
}